﻿function ItemSearchModule_HandleResults(response) {
    if ($('.itemSearchModule .cmsItemList') && response.Configuration.SummaryView.length != 0)
        //Get rendered HTML results from View
        $.post(location.protocol + '//' + location.host + '/cms/info/MethodHandlerView/OpenQuarters.WebQuarters.Modules.ItemSearch,ItemSearchModule,AjaxRenderResults/' + escape(response.Configuration.SummaryView), { 'itemType': response.ItemType, 'jsonItems': $.compactJSON(response.Items) }, function(data) { ItemSearchModule_UpdateResults(data); })
    if ($('.itemSearchModule .cmsItemPager') && response.Configuration.PaginationView.length != 0)
    //Get rendered HTML results from View
        $.post(location.protocol + '//' + location.host + '/cms/info/MethodHandlerView/OpenQuarters.WebQuarters.Modules.ItemSearch,ItemSearchModule,AjaxRenderPager/' + escape(response.Configuration.PaginationView), { 'itemType': response.ItemType, 'jsonPaginationData': $.compactJSON(response.Pagination) }, function(data) { ItemSearchModule_UpdatePagers(data); })
}

function ItemSearchModule_UpdateResults(data) {
    // Update document with rendered html
    var resultsViews = $('.itemSearchModule .cmsItemList');
    resultsViews.before(data); 
    resultsViews.remove();
}

function ItemSearchModule_UpdatePagers(data) {
    // Update document with rendered html
    var pagerViews = $('.itemSearchModule .cmsItemPager');
    pagerViews.before(data);
    pagerViews.remove();
}
